<template>
  <div class="container">
    <navigate>消息列表</navigate>
    <div class="container_main">
      <div v-for="(item, index) in message" :key="index" class="item">
        <div class="flex_row" @click="hrefDetail" v-if="false">
          <img :src="item.icon" alt="" />
          <div class="info">
            <div class="title_date between flex_row flex_align_center">
              <div class="text">
                {{ item.title }}
              </div>

              <div class="date">24/11/05 02:26</div>
            </div>
            <div class="publish_person">发布人员：{{ item.publishPerson }}</div>
            <div class="task_name">{{ item.taskName }}</div>
            <div class="label">
              <div>普通测评</div>
              <div>剩余{{ "7" }}天</div>
            </div>
          </div>
        </div>
        <div class="flex_row" v-if="false">
          <img :src="item.icon" alt="" />
          <div class="info">
            <div class="title_date between flex_row flex_align_center">
              <div class="text">
                {{ item.title }}
              </div>

              <div class="date">24/11/05 02:26</div>
            </div>
            <div class="publish_person">测评量表：{{ item.scaleEvaluate }}</div>
            <div class="task_name">{{ item.taskName }}</div>
            <div class="label">
              <div>普通测评报告</div>
            </div>
          </div>
        </div>

        <div class="flex_row">
          <img :src="joinUrlImg(item.img)" alt="" />
          <div class="info">
            <div class="title_date between flex_row flex_align_center">
              <div class="text">
                {{ item.title }}
              </div>

              <div class="date">
                {{ convertTimestampToDateTime(item.time) }}
              </div>
            </div>

            <div class="content">{{ item.content }}</div>
            <!-- <div class="label">
              <div>用户操作</div>
            </div> -->
          </div>
        </div>

        <div class="flex_row" v-if="false">
          <img :src="item.icon" alt="" />
          <div class="info">
            <div class="title_date between flex_row flex_align_center">
              <div class="text">
                {{ item.title }}
              </div>
              <div class="date">24/11/05 02:26</div>
            </div>
            <div class="counselor">咨询师：{{ item.counselor }}</div>

            <div class="content">{{ item.content }}</div>
            <div class="label">
              <div>线上咨询</div>
            </div>
          </div>
        </div>
      </div>

      <div class="more_data" @click="loadData">加载更多数据</div>
    </div>
  </div>
</template>

<script>
import { queryLogList } from "@/api/my/index";
import { joinUrlImg } from "@/utils/setUrlImg";
import { convertTimestampToDateTime } from "@/utils/time";
export default {
  data() {
    return {
      pageSize: 10,
      page: 1,
      total: null,
      message: [],
      message1: [
        {
          type: 1,
          icon: require("@/assets/images/my/message/1.png"),
          title: "测评任务通知",
          publishPerson: "黄老师",
          taskName: "2024下学年开学全年级普查",
          time: "24/11/05 02:26",
        },
        {
          type: 2,
          icon: require("@/assets/images/my/message/2.png"),
          title: "报告生成通知",
          scaleEvaluate: "国际焦虑自评量表(SAS)",
          taskName: "2024下学年开学全年级普查",
          time: "24/11/05 02:26",
        },
        {
          type: 3,
          icon: require("@/assets/images/my/message/3.png"),
          title: "系统通知",
          content: "您于2024/11/05 02:26:16更新了个人自评表。",
          time: "24/11/05 02:26",
        },
        {
          type: 4,
          icon: require("@/assets/images/my/message/4.png"),
          title: "咨询预约消息",
          counselor: "李元远",
          content: "咨询师向您发布新的测评任务啦~",
          time: "24/11/05 02:26",
        },
      ],
    };
  },
  created() {
    this.getLogList();
  },
  methods: {
    joinUrlImg,
    convertTimestampToDateTime,
    async getLogList() {
      let par = {
        pageSize: this.pageSize,
        page: this.page,
      };
      let res = await queryLogList(par);
      if (res.code == 200) {
        this.message.push(...res.data.data);
      }
    },
    loadData() {
      this.page += 1;
      this.getLogList();
    },
  },
};
</script>

<style lang="less" scoped>
@import "./css/index.less";
</style>
